package com.rcmd.cmd;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;

public class DataCommand extends Command{
	protected byte[] data ;
	public DataCommand(byte [] data){
		super(Command.DATA) ;
		this.data = data ;
	}
	public DataCommand(){
		this(null) ;
	}
//	public DataCommand(){
//		super(Command.DATA) ;
//	}
	public byte[] getData() {
		return data;
	}
	public void setData(byte[] data) {
		this.data = data;
	}
	
	@Override
	protected void read(ObjectInput in) throws IOException,
			ClassNotFoundException {
		int len = in.readInt() ;
		data = new byte[len] ;
		in.readFully(data) ;
	}
	@Override
	protected void write(ObjectOutput out) throws IOException {
		out.writeInt(data.length) ;
		out.write(data) ;
	}
}
